<?php
$output = array();

if (!isset($_GET["email"])) {
    echo("No email specified");
    exit();
}
$email = urldecode($_GET["email"]);

// import database connection variables and connectToMysql method
require_once __DIR__ . '/db_config.php';

$mysqli = connectToMysql();
$query = "SELECT user.* FROM User user where email = '" . $email ."'";

if ($result = $mysqli->query($query)) {
    /* fetch object array */
    $row = $result->fetch_array();
	if ($row != null) {
		$output = array_map('utf8_encode', $row);
	}
    $result->close();
}

/* close connection */
$mysqli->close();

$finalResult = json_encode($output, JSON_NUMERIC_CHECK);

echo $finalResult;
?>